package com.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pojo.Checkout;
import com.service.CheckoutService;
import com.vo.CheckoutVo;
import com.vo.DataVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author mornd
 * @date 2020/12/4 - 17:26
 */
@RestController
@RequestMapping("/checkout")
public class CheckoutController {
    @Autowired
    private CheckoutService checkoutService;

    /**
     * 查询退房记录
     *
     * @param checkoutVo
     * @return
     */
    @RequestMapping("/list")
    public String findCheckoutList(CheckoutVo checkoutVo) {
        PageHelper.startPage(checkoutVo.getPage(), checkoutVo.getLimit());
        PageInfo<Checkout> pageInfo = new PageInfo<Checkout>(checkoutService.findCheckoutList(checkoutVo));
        return JSON.toJSONString(new DataVO<Checkout>(pageInfo.getTotal(), pageInfo.getList()));
    }
}
